package top.haijunit.sample.navi.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zhanghaijun
 * @date 2024/7/5 14:24
 * @description [一句话描述该类的功能]
 */
@Configuration(proxyBeanMethods = false)
public class CustomWebConfigurer implements WebMvcConfigurer {

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI().info(new Info()
                .title("SpringBoot相关的测试示例")
                .description("SpringBoot相关的测试示例")
                .version("1.0.0")
                .contact(new Contact().name("zhanghaijun").email("zhanghaijun_java@163.com"))
                .license(new License().name("Apache 2.0").url("http://springdoc.org"))
        );
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:/doc.html");
        WebMvcConfigurer.super.addViewControllers(registry);
    }
}
